#pragma once

#include "pch.h"

struct Info
{
    std::string path;

    std::vector<std::string> tokens1;
    std::vector<std::string> tokens2;
    std::vector<std::string> splitString(const std::string &s, char delimiter)
    {
        std::vector<std::string> tokens;
        std::stringstream ss(s);
        std::string token;
        while (std::getline(ss, token, delimiter))
        {
            tokens.push_back(token);
        }
        return tokens;
    }
    Info() = default;

    Info(const std::string &path) : path(path)
    {
        tokens1 = splitString(path, '/');
        for (auto token : tokens1)
        {
            token[0] -= 32;
            tokens2.push_back(token);
        }
    }

    std::string GetBy_(char v)
    {
        std::string res;
        for (int i = 0; i < tokens1.size(); i++)
        {
            res += tokens1[i];
            if (i != tokens1.size()-1)
            {
                res += v;
            }
        }
        return res;
    }

    void CreateIndex()
    {

        std::ofstream ofs("temp.txt", std::ios::app);

        ofs << GetBy_('_');
        ofs << "\n";

        ofs.flush();
        ofs.close();
    }
    void Create(std::string v)
    {
        std::string currentPath = "";

        for (int i = 0; i < tokens1.size(); i++)
        {
            const auto &token = tokens1[i];
            currentPath += (token + "/");

            if (!fs::exists(currentPath + v))
            {
                std::ofstream ofs(currentPath + v);

                const char *value =
                    R"(cmake_minimum_required(VERSION 3.5.0)
set(CMAKE_CXX_STANDARD 17)
)";

                ofs << value;
                ofs.close();
            }
        }
    }
};
